<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="/taglibs.jsp"%>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport"
	content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link href="${ctx}/resources/semanticui/semantic.min.css"
	rel="stylesheet" type="text/css" />
<link href="${ctx}/resources/apps.css" rel="stylesheet" type="text/css" />
<title>猎头信息</title>
</head>
<body>

	<div class="ui segment" id="n-page">

		<div class="ui segment" id="n-content">

			<form class="ui form">
				<p>1.设置个人信息</p>

				<div class="field">
					<label>姓名</label>
					<div class="ui input">
						<input type="text" name="name" id="name" placeholder="请输入姓名"
							value="${hunter.name}">
					</div>
				</div>
				<div class="field">
					<label>英文名</label>
					<div class="ui input">
						<input type="text" name="englishname" id="englishname"
							placeholder="请输入英文名" value="${hunter.englishname}">
					</div>
				</div>
				<div class="field">
					<label>身份证</label>
					<div class="ui input">
						<input type="text" name="idnumber" id="idnumber"
							placeholder="请输入身份证" value="${hunter.idnumber}">
					</div>
				</div>
				<div class="field">
					<label>从业时间</label>
					<div class="ui input">
						<input type="text" name="workage" id="workage"
							placeholder="请输入从业时间" value="${hunter.workage}">
					</div>
				</div>
				<p>2.完善基本信息</p>
				<div class="field">
					<label>城市</label> <select name="cityId" id="cityId"
						class="ui search dropdown">
						<option value="">请输入所在城市</option>
						<c:forEach items="${cities}" var="city">
							<c:choose>
								<c:when test="${hunter.cityId == city.id }">
									<option value="${city.id}" selected="selected">${city.name}</option>
								</c:when>
								<c:otherwise>
									<option value="${city.id}">${city.name}</option>
								</c:otherwise>
							</c:choose>
						</c:forEach>
					</select>
				</div>


				<div class="field">
					<label>擅长领域</label> <select class="ui search  dropdown"
						name="majordomain1" id="majordomain1">
						<option value="">请输入擅长领域</option>
						<c:forEach items="${domains}" var="dm">
							<c:choose>
								<c:when test="${dm.id == hunter.majordomain1 }">
									<option value="${dm.id}" selected="selected">${dm.name}</option>
								</c:when>
								<c:otherwise>
									<option value="${dm.id}">${dm.name}</option>
								</c:otherwise>
							</c:choose>
						</c:forEach>
					</select>
				</div>
				<div class="field">
					<label>擅长领域</label> 
					<select class="ui search  dropdown"
						name="majordomain2" id="majordomain2">
						<option value="">请输入擅长领域</option>
						<c:forEach items="${domains}" var="dm">
							<c:choose>
								<c:when test="${dm.id == hunter.majordomain2 }">
									<option value="${dm.id}" selected="selected">${dm.name}</option>
								</c:when>
								<c:otherwise>
									<option value="${dm.id}">${dm.name}</option>
								</c:otherwise>
							</c:choose>
						</c:forEach>
					</select>
				</div>
				<div class="field">
					<label>擅长领域</label> <select class="ui search  dropdown"
						name="majordomain3" id="majordomain3">
						<option value="">请输入擅长领域</option>
						<c:forEach items="${domains}" var="dm">
							<c:choose>
								<c:when test="${dm.id == hunter.majordomain3 }">
									<option value="${dm.id}" selected="selected">${dm.name}</option>
								</c:when>
								<c:otherwise>
									<option value="${dm.id}">${dm.name}</option>
								</c:otherwise>
							</c:choose>
						</c:forEach>
					</select>
				</div>



				<div class="field">
					<label>电子邮箱</label>
					<div class="ui input">
						<input type="email" name="cemail" id="cemail"
							placeholder="请输入您的邮箱" value="${hunter.email}">
					</div>
				</div>
				<div class="field">
					<label>擅长职能</label>
					 <select name="bestdomain" id="bestdomain"
						multiple="" class="ui fluid normal dropdown">
						<option value="">擅长智能</option>
						<option value="c-level">C-level</option>
						<option value="sbt">销售/商务/培训</option>
						<option value="market">市场/产品</option>
						<option value="client">客户服务/技术支持</option>
						<option value="factory">工厂</option>
						<option value="r&d">研发</option>
						<option value="TRB">临床试验/注册/医学事务</option>
						<option value="CRM">采购/物料/供应链管理</option>
						<option value="Health">大健康投资</option>
						<option value="net">IT/互联网</option>
						<option value="human">人力资源</option>
						<option value="tax">财务/审计/税务</option>
						<option value="public">公共/媒介</option>
					</select>
				</div>
				<div class="field">
					<label>个人介绍</label>
					<div class="ui input">
						<input type="text" name=advantage id="advantage"
							placeholder="请输入个人介绍" value="${hunter.advantage}">
					</div>
				</div>

<%--				<div class="field">--%>
<%--					<label>备注</label>--%>
<%--					<div class="ui input">--%>
<%--						<input type="text" name="comment" id="comment" placeholder="请输入备注"--%>
<%--							value="${hunter.comment}">--%>
<%--					</div>--%>
<%--				</div>--%>
				<div class="field">
					<label>服务内容</label> <a class="ui tag label">简历修改</a> <a
						class="ui teal tag label">职位推荐</a> <a class="ui  tag label">面试辅导</a>
					<a class="ui  tag label">职业规划</a> <a class="ui  tag label">薪酬建议以及谈判</a>
					<a class="ui  tag label">专属职业经纪人</a>
				</div>

				<input type="hidden" name="hunterid" id="hunterid"
					value="${hunter.id}" /> <input type="hidden" name="phone"
					id="phone" placeholder="请输入姓名" value="${hunter.phone}">
			</form>
		</div>
		<!--
        <div class="ui segment" id="btn-next2">
            <div class="fluid ui button" id="next">下一步</div>
        </div>
        -->
		<div class="ui center aligned segment" id="choice-buttons">
			<div class="two ui buttons">
				<div class="ui button active dog" id="next">下一步</div>
				<div class="ui button active dog" id="closeit">回首页</div>
			</div>
		</div>
	</div>

	<script src="${ctx}/resources/jweixin-1.0.0.js"></script>
	<script src="${ctx}/resources/semanticui/components/dropdown.js"></script>
	<script src="${ctx}/resources/semanticui/jquery-2.1.4.min.js"></script>
	<script src="${ctx}/resources/semanticui/semantic.js"
		type="text/javascript"></script>



	<script type="text/javascript">

wx.config({
    debug: false, 
    appId: "${config.appid}",  
    timestamp: ${config.currenttimestamp},  
    nonceStr: "${config.nonceStr}", 
    signature: "${config.signatureStr}", 
    jsApiList: ['checkJsApi',
        'onMenuShareTimeline',
        'onMenuShareAppMessage',
        'onMenuShareQQ',
        'onMenuShareWeibo',
        'hideOptionMenu',
        'closeWindow']  
});

    var handler = { 
        activate: function() { 
            $(this).addClass('active').siblings().removeClass('active'); 

            if($(this).attr('id') == 'closeit') {
                wx.closeWindow();
            }

            if($(this).attr('id') == 'next') {
                var name = $("#name").val();
               
                var majordomain1  = $("#majordomain1").val();
                var majordomain2  = $("#majordomain2").val();
                var majordomain3  = $("#majordomain3").val();
                var workage   = $("#workage").val();
                var advantage = $("#advantage").val();
                var phone  = $("#phone").val();
                var email  = $("#cemail").val();
                var hunterid  = $("#hunterid").val();
                var comment   = $("#comment").val();
                var cityid    = $("#cityId").val();
                var idnumber  = $("#idnumber").val();
                var englishname  = $("#englishname").val();
                var bestdomain  = $("#bestdomain").val();
                //var servicesTag  = $("#servicesTag").val();
                
                if(!bestdomain || bestdomain=="") {
                  alert("您必须输入您的擅长职能");
                  return false;
              }
              if(bestdomain.length > 100) {
                  alert("您输入的擅长智能太长");
                  return false;
              }
                if(!name || name=="") {
                    alert("您必须输入您的名字");
                    return false;
                }
                if(name.length > 40) {
                    alert("您输入的名字太长");
                    return false;
                }
                if(!englishname || englishname=="") {
                    alert("您必须输入您的英文名");
                    return false;
                }
                if(englishname.length > 50) {
                    alert("您输入的英文名太长");
                    return false;
                }
                if(!idnumber || idnumber=="") {
                    alert("您必须输入您的身份证");
                    return false;
                }
                if(idnumber.length > 18) {
                    alert("您输入的身份证太长");
                    return false;
                }
                if(!comment || comment=="") {
                    alert("您必须输入备注");
                    return false;
                }
                if(comment.length > 80) {
                    alert("您输入的备注太长");
                    return false;
                }
                
                if(!majordomain1) {
                    alert("您必须选择一个擅长领域1");
                    return false;
                }
                if(!majordomain2) {
                    alert("您必须选择一个擅长领域2");
                    return false;
                }
                if(!majordomain3) {
                    alert("您必须选择一个擅长领域3");
                    return false;
                }
                if(!workage) {
                    alert("您必须输入从业时间");
                    return false;
                }
               
                if(!/^[0-9]+$/.test(workage) || workage < 0 || workage > 60) {
                    alert("您必须输入从业时间"); 
                    return false;
                }
                
                if(!advantage) {
                    alert("您必须输入优势/专长");
                    return false;
                }
               
                if(!email) {
                    alert("您必须输入电子邮箱");
                    return false;
                }
                var re = /[A-Z0-9._%+-]+@[A-Z0-9.-]+.[A-Z]{2,4}/igm;
                if(!re.test(email)) {
                    alert("您必须输入合格的电子邮箱");
                    return false;
                }

                $(this).addClass('disabled');
                var that = this;

                var postUrl = '${ctx}/wechat/hunter/create.do';
                var param = {};
                param['name']  = name;
                param['englishname']  = englishname;
                param['idnumber']  = idnumber;
                param['cityId']  = cityid;
             
                param['majordomain1'] = majordomain1;
                param['majordomain2'] = majordomain2;
                param['majordomain3'] = majordomain3;
                param['workage']  = workage;
                param['advantage'] = advantage;
                param['email']  = email;
                param['phone']  = phone;
                param['comment'] = comment;
                if (hunterid) { 
                    param['id'] = hunterid;
                }
                param['bestdomain']= bestdomain[0];
                param['serviceTags']= "";
               var srvtags = $('.tag.teal');
               srvtags.each(function(index){
                 //alert(index);
                 //alert($(this).text());
                 param['serviceTags']=param['serviceTags']+ ',' +$(this).text();
                 
               }); 
                
                
                $.ajax({ 
                    url: postUrl, 
                    type: "POST", 
                    data: param,
                    success: function(data){ 
                        if(data.errorcode=="0") {
                            var hunter = data.data;
                            location.href = '${ctx}/wechat/hunter/toUploadFile.page?hunterId='+hunterid;
                            return;
                        } else if(data.errorcode=="1") {
                            alert(data.msg);
                            location.href = '${ctx}/wechat/hunter/main.page';
                            return;
                        } else{
                            alert(data.msg);
                            $(that).removeClass('disabled');
                        }
                    }, 
                    error: function() { 
                        alert("服务出错，请稍后尝试"); 
                        $(that).removeClass('disabled');
                    } 
                });
            }
        } 
    };

    
   var tag = {
              activate:function(){
                if($(this).hasClass('teal')){
                  $(this).removeClass('teal'); 
                }else{
                  $(this).addClass('teal'); 
                }
                
              }
   };
    $(document).ready(function() { 
     $('#bestdomain')  .dropdown({
  allowAdditions: true
}    );
            $('.button').on('click', handler.activate);

            $('.tag').on('click', tag.activate);
            $('.dropdown').dropdown({
                fullTextSearch:true,
            });
            wx.ready(function() { 
            wx.hideOptionMenu();
        });
    });

</script>
</body>
</html>